package utils;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import logicInterface.GeneralManagerLogicInterface;
import main.Main;

import components.MyButton;
import components.MyFrame;

public class MyActionListener implements ActionListener{

	public void actionPerformed(ActionEvent e) {
		MyButton button=(MyButton) e.getSource();
		String action=button.getButtonAction();
		MyFrame mf=Main.getMf();
		mf.updateVO();
		String s=null;
		GeneralManagerLogicInterface logic=Main.getLogic();
		Method m;
		try {
			m = logic.getClass().getDeclaredMethod(action);
			s=(String) m.invoke(logic);
		} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e1) {
			e1.printStackTrace();
		}
		mf.changePanel(PanelFactory.makePanel(s));
	}

}
